package com.ruoyi.awards1.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.awards1.domain.JwTeachAwards;
import com.ruoyi.awards1.service.IJwTeachAwardsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教师获奖情况Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/awards1/awards1")
public class JwTeachAwardsController extends BaseController
{
    @Autowired
    private IJwTeachAwardsService jwTeachAwardsService;

    /**
     * 查询教师获奖情况列表
     */
    @PreAuthorize("@ss.hasPermi('awards1:awards1:list')")
    @GetMapping("/list")
    public TableDataInfo list(JwTeachAwards jwTeachAwards)
    {
        startPage();
        List<JwTeachAwards> list = jwTeachAwardsService.selectJwTeachAwardsList(jwTeachAwards);
        return getDataTable(list);
    }

    /**
     * 导出教师获奖情况列表
     */
    @PreAuthorize("@ss.hasPermi('awards1:awards1:export')")
    @Log(title = "教师获奖情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JwTeachAwards jwTeachAwards)
    {
        List<JwTeachAwards> list = jwTeachAwardsService.selectJwTeachAwardsList(jwTeachAwards);
        ExcelUtil<JwTeachAwards> util = new ExcelUtil<JwTeachAwards>(JwTeachAwards.class);
        util.exportExcel(response, list, "教师获奖情况数据");
    }

    /**
     * 获取教师获奖情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('awards1:awards1:query')")
    @GetMapping(value = "/{teaId}")
    public AjaxResult getInfo(@PathVariable("teaId") Long teaId)
    {
        return success(jwTeachAwardsService.selectJwTeachAwardsByTeaId(teaId));
    }

    /**
     * 新增教师获奖情况
     */
    @PreAuthorize("@ss.hasPermi('awards1:awards1:add')")
    @Log(title = "教师获奖情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JwTeachAwards jwTeachAwards)
    {
        SysUser user= SecurityUtils.getLoginUser().getUser();
        jwTeachAwards.setDeptId(104L);
        jwTeachAwards.setUserId(user.getUserId());
        return toAjax(jwTeachAwardsService.insertJwTeachAwards(jwTeachAwards));
    }

    /**
     * 修改教师获奖情况
     */
    @PreAuthorize("@ss.hasPermi('awards1:awards1:edit')")
    @Log(title = "教师获奖情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JwTeachAwards jwTeachAwards)
    {
        return toAjax(jwTeachAwardsService.updateJwTeachAwards(jwTeachAwards));
    }

    /**
     * 删除教师获奖情况
     */
    @PreAuthorize("@ss.hasPermi('awards1:awards1:remove')")
    @Log(title = "教师获奖情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teaIds}")
    public AjaxResult remove(@PathVariable Long[] teaIds)
    {
        return toAjax(jwTeachAwardsService.deleteJwTeachAwardsByTeaIds(teaIds));
    }
}
